package com.order.itemcategoryproject.service.lmpl;

import com.order.itemcategoryproject.mapper.DBlOrderHdOnlineMapper;
import com.order.itemcategoryproject.pojo.DBlOrderHdOnline;
import com.order.itemcategoryproject.service.DBlOrderHdOnlineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.util.List;


@Service
public class DBlOrderHdOnlineServicelmpl implements DBlOrderHdOnlineService {


    @Autowired
    private DBlOrderHdOnlineMapper DBlOrderHdOnlineMapper;


    /**
     * 添加订单信息
     * @param DBlOrderHdOnline
     */
    @Override
    public int insertOrderInfo(DBlOrderHdOnline DBlOrderHdOnline) {
        return DBlOrderHdOnlineMapper.insertOrderInfo(DBlOrderHdOnline);
    }

    /**
     * 根据制单人编号获取当前制单人创建的所有订单
     * @param staffId
     * @return
     */
    @Override
    public List<DBlOrderHdOnline> getOrderInfoByStaffId(String staffId) {
        return DBlOrderHdOnlineMapper.getOrderInfoByStaffId(staffId);
    }

    /**
     * 根据订单编号获取订单信息
     * @param orderId
     * @return
     */
    @Override
    public DBlOrderHdOnline getOrderinfoByOrderId(String orderId) {
        return DBlOrderHdOnlineMapper.getOrderInfoByOrderId(orderId);
    }


    /**
     * 根据订单编号更新订单状态
     * @param orderId
     * @return
     */
    @Override
    public int updateOrderStatusByOrderId(String orderId) {
        return DBlOrderHdOnlineMapper.updateOrderStatusByOrderId(orderId);
    }


    /**
     * 根据订单编号删除订单信息
     * @param orderId
     * @return
     */
    @Override
    public int deleteOrderInfoByOrderId(String orderId) {
        return DBlOrderHdOnlineMapper.deleteOrderInfoByOrderId(orderId);
    }

    /**
     * 根据订单编号逻辑删除订单信息
     * 将cancelSign修改为Y
     * @param orderId
     * @return
     */
    @Override
    public int updateOrderByOrderId(String orderId) {
        return DBlOrderHdOnlineMapper.updateOrderByOrderId(orderId);
    }


    /**
     * 根据订单编号更新该订单备注
     * @param orderId
     * @param content
     * @return
     */
    @Override
    public int updateRemarkContentByOrderId(String orderId, String content) {
        return DBlOrderHdOnlineMapper.updateRemarkContentByOrderId(orderId, content);
    }


    /**
     * 根据订单编号更新当前订单的值
     * @param orderId
     * @param totalNum
     * @param totalPrice
     * @return
     */
    @Override
    public int updateOrderInfoByOrderId(String orderId, int totalNum, double totalPrice, double totalVolume, double totalWeight) {
        return DBlOrderHdOnlineMapper.updateOrderInfoByOrderId(orderId, totalNum, totalPrice, totalVolume, totalWeight);
    }

    /**
     * 根据客户编号获取当前客户下最新创建的订单
     * @param createStaffId
     * @return
     */
    @Override
    public DBlOrderHdOnline selectNewOrderInfoDesc(String createStaffId) {
        return DBlOrderHdOnlineMapper.selectNewOrderInfoDesc(createStaffId);
    }


    /**
     * 根据订单编号和客户名称来更新当前订单预计付款时间
     * @param orderId
     * @param createStaffId
     * @param esPaymentDate
     * @return
     */
    @Override
    public int updateEsPaymentTimeByOrderIdAndCreateStaffId(String orderId, String createStaffId, Date esPaymentDate) {
        return DBlOrderHdOnlineMapper.updateEsPaymentTimeByOrderIdAndCreateStaffId(orderId, createStaffId, esPaymentDate);
    }

    /**
     * 根据订单编号更新当前订单总数量和总价格
     * @param orderId
     * @return
     */
    @Override
    public int updateOrderTotalNumAndTotalPrice(String orderId) {
        return DBlOrderHdOnlineMapper.updateOrderTotalNumAndTotalPrice(orderId);
    }
}
